﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Data.Linq.Mapping;
using System.IO.IsolatedStorage;

namespace G.Reader.Data
{
    [Table]
    public class BookAudio : BaseTable
    {
        private int id;

        [Column(IsPrimaryKey = true, IsDbGenerated = true, DbType = "INT NOT NULL Identity", CanBeNull = false, AutoSync = AutoSync.OnInsert)]
        public int ID
        {
            get
            {
                return id;
            }
            set
            {
                if (id != value)
                {
                    NotifyPropertyChanging("ID");
                    id = value;
                    NotifyPropertyChanged("ID");
                }
            }
        }

        private int bookId;

        [Column]
        public int BookId
        {
            get
            {
                return bookId;
            }
            set
            {
                if (bookId != value)
                {
                    NotifyPropertyChanging("BookId");
                    bookId = value;
                    NotifyPropertyChanged("BookId");
                }
            }
        }
        private long size;
        /// <summary>
        /// 音频文件大小，单位为字节
        /// </summary>
        [Column]
        public long Size
        {
            get
            {
                return size;
            }
            set
            {
                if (size != value)
                {
                    NotifyPropertyChanging("Size");
                    size = value;
                    NotifyPropertyChanged("Size");
                }
            }
        }

        private int paragraphIndex;
        /// <summary>
        /// 声音文件对应的书中的段落索引
        /// </summary>
        [Column]
        public int ParagraphIndex
        {
            get
            {
                return paragraphIndex;
            }
            set
            {
                if (paragraphIndex != value)
                {
                    NotifyPropertyChanging("ParagraphIndex");
                    paragraphIndex = value;
                    NotifyPropertyChanged("ParagraphIndex");
                }
            }
        }

        public string BookPath
        {
            get
            {
                return string.Format("{0}_{1}.wav", this.BookId, this.ParagraphIndex); 
            }
        }

    }
}
